from lbforaging.foraging.environment import ForagingEnv

# import os
# import re
# import importlib
# from datetime import datetime

# # 定义目录路径
# directory = 'src/envs/lb-foraging/lbforaging/foraging/'

# # 列出所有文件
# files = os.listdir(directory)

# # 匹配 environment_{timing}.py 格式的文件
# pattern = r'environment_(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})\.py'
# environment_files = [f for f in files if re.match(pattern, f)]

# # 如果没有找到符合条件的文件，返回错误提示
# if not environment_files:
#     raise FileNotFoundError("No environment files found with the pattern environment_{timing}.py")

# # 找到时间最晚的文件
# max_timing_file = max(environment_files, key=lambda f: datetime.strptime(re.search(pattern, f).group(1), "%Y-%m-%d_%H-%M-%S"))

# # 获取模块名，不带.py后缀
# module_name = max_timing_file[:-3]

# # 动态导入模块
# module_path = f"lbforaging.foraging.{module_name}"
# environment_module = importlib.import_module(module_path)

# # 从模块中导入 ForagingEnv
# ForagingEnv = getattr(environment_module, 'ForagingEnv')

# # 使用 ForagingEnv
# # 示例：env = ForagingEnv()
